﻿
project(GenerateReport)


#add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
############################################################
# Create an executable
############################################################

#输出目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_OUTPUT_BIN_DIR})

#所有.ui文件
file(GLOB ALL_UI "*.ui")
#所有.h文件
FILE(GLOB SRC_H_FILES "*.h" "./QJsonHelper/*.h")
#所有.cpp文件
FILE(GLOB SRC_CPP_FILES "*.cpp" "./QJsonHelper/*.cpp")

SET(DIR_RESOURCES "${CMAKE_SOURCE_DIR}/Resources")
SET(SRC_QRC_FILES 
    "${DIR_RESOURCES}/image.qrc"
    "${LIBRARY_ElaWidgetTools_INCLUDE}/ElaWidgetTools.qrc"
)

# 定义QCustomPlot DLL导入符号宏定义
ADD_DEFINITIONS("-DQCUSTOMPLOT_USE_LIBRARY")

add_executable(${PROJECT_NAME} 
    ${ALL_UI}
    ${SRC_H_FILES}
    ${SRC_CPP_FILES}
    ${SRC_QRC_FILES}
)

# 包含头文件目录
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} 
    PRIVATE
    ${CMAKE_SOURCE_DIR}
)

# 配置编译选项
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
    SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
    SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
ENDIF()    


find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets)

TARGET_LINK_DIRECTORIES(${PROJECT_NAME} PRIVATE ${PROJECT_OUTPUT_BIN_DIR})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} BaseModule)
ADD_DEPENDENCIES(${PROJECT_NAME} BaseModule)

#libreoffice路径设置
SET(LIBREOFFICE_DIR ${LIBRARY_THIRDPARTY_DIR}/Libs/windows-x86_64/libreoffice)
INCLUDE_DIRECTORIES(${LIBREOFFICE_DIR}/include)
FILE(GLOB LIBRARY_libreoffice_LIBS "${LIBREOFFICE_DIR}/lib${PROJECT_BUILD_TYPE_POSTFIX}/*.lib")
FILE(GLOB LIBRARY_libreoffice_BINS "${LIBREOFFICE_DIR}/bin${PROJECT_BUILD_TYPE_POSTFIX}/*.*")
FILE(COPY ${LIBRARY_libreoffice_BINS}  DESTINATION ${PROJECT_OUTPUT_BIN_DIR})
#FILE(COPY ${LIBREOFFICE_DIR}/program  DESTINATION ${PROJECT_OUTPUT_DIR})
#FILE(COPY ${LIBREOFFICE_DIR}/share  DESTINATION ${PROJECT_OUTPUT_DIR})

INCLUDE_DIRECTORIES(${LIBREOFFICE_DIR}/include  ${LIBRARY_ElaWidgetTools_INCLUDE} ${LIBRARY_QCustomPlot_INCLUDE}) 

#UI组件库
FILE(COPY ${LIBRARY_ElaWidgetTools_BINS}  DESTINATION ${PROJECT_OUTPUT_BIN_DIR})

#QCustomPlot组件库
FILE(COPY ${LIBRARY_QCustomPlot_BINS}  DESTINATION ${PROJECT_OUTPUT_BIN_DIR})

target_link_libraries(${PROJECT_NAME} ${VLD_DIR}/lib/vld.lib)
target_link_libraries(${PROJECT_NAME} ${LIBRARY_libreoffice_LIBS} ${LIBRARY_ElaWidgetTools_LIBS} ${LIBRARY_QCustomPlot_LIBS})

